function binStuff = cBinners_dev(Z, castIndicator, LEmask)
    global DB
    query = ['SELECT GlobalQuantity FROM Global WHERE GlobalTypeID='...
             '(SELECT GlobalTypeID From GlobalType WHERE GlobalTypeName='...
             '''binSize'')'];
    curs = '';
    try
        curs = exec(DB.DB, query);
        curs = fetch(curs);
        binSize = curs.Data{:};
        nBin = ceil(max(Z)/binSize - 0.5);
        dnZ = Z(~castIndicator); 
        dnMask = LEmask(~castIndicator)==0;
        dnBinner = zeros(nBin, numel(dnZ));
        upZ = Z(logical(castIndicator));
        upMask = LEmask(logical(castIndicator))==0;
        upBinner = zeros(nBin, numel(upZ));
        binStuff = struct('sz', binSize, 'N', nBin, 'Z', binSize*(1:nBin)');
        for i=1:nBin
            dnBinner(i,:) = (dnZ >= binSize*(i - 0.5)) & ...
                            (dnZ < binSize*(i + 0.5)) & dnMask;
            upBinner(nBin-i+1,:) = (upZ > binSize*(i - 0.5)) & ...
                                   (upZ <= binSize*(i + 0.5)) & upMask;
        end
        binStuff.binner = [dnBinner, 0*upBinner; 0*dnBinner, upBinner];
        binStuff.ns = sum(binStuff.binner, 2);
    catch ME
        if isempty(curs.Message)
            binStuff = getReport(ME, 'basic', 'hyperlinks', 'off');
        else
            binStuff = curs.Message;
        end
    end
end